<script lang="ts" setup>
import { reactive, onMounted } from 'vue'
import baseDefault from './baseDefault.vue'
import customButton from './customButton.vue'
import hiddenButton from './hiddenButton.vue'
import QuickCode from '@/components/QuickCode/index.vue'
import { getFile } from '@/api/file'

const form = reactive({
  defaultCode: '',
  customButtonCode: '',
  hiddenButtonCode: '',
})
onMounted(() => {
  getFile('/template/search/baseDefault.vue').then((res: any) => {
    form.defaultCode = res
  })
  getFile('/template/search/customButton.vue').then((res: any) => {
    form.customButtonCode = res
  })
  getFile('/template/search/hiddenButton.vue').then((res: any) => {
    form.hiddenButtonCode = res
  })
})
</script>
<template>
  <div class="component-demo">
    <el-card>
      <template #header>
        <div class="card-header card-name">
          <h2>默认</h2>
        </div>
        <div class="card-description">
          <p>常规搜索</p>
        </div>
      </template>
      <base-default></base-default>
      <quick-code :autodetect="true" :code="form.defaultCode"></quick-code>
    </el-card>
    <el-card class="item" shadow="always">
      <template #header>
        <div class="card-header card-name">
          <h2>自定义按钮</h2>
        </div>
        <div class="card-description">
          <p>
            通过设置属性search-button-name="搜索"自定义查询按钮文本名称，通过设置属性reset-button-name="重置"自定义清空按钮文本名称
          </p>
        </div>
      </template>
      <custom-button></custom-button>
      <quick-code :autodetect="true" :code="form.customButtonCode"></quick-code>
    </el-card>
    <el-card class="item" shadow="always">
      <template #header>
        <div class="card-header card-name">
          <h2>隐藏清空按钮</h2>
        </div>
        <div class="card-description">
          <p>通过设置属性:hidden-reset-button="false"隐藏清空按钮</p>
        </div>
      </template>
      <hidden-button></hidden-button>
      <quick-code :autodetect="true" :code="form.hiddenButtonCode"></quick-code>
    </el-card>
  </div>
</template>
<style lang="scss" scoped>
.component-demo {
  .card-name {
  }
  .card-description {
    margin-top: 10px;
  }
  .item {
    margin-top: 10px;
  }
}
</style>
